var React = require('react');
var AppView = require('../../common/component/view/app-view.node');
var ModalDialog = require('../../common/component/dialog/modal-dialog.node');
var ModalBody = require('../../common/component/dialog/modal-body.node');
var ModalFooter = require('../../common/component/dialog/modal-footer.node');
var AssignResourceDialog = require('./assign-resource-dialog.node');
var AssignPermissionDialog = require('./assign-permission-dialog.node');

module.exports = <>
  <AppView viewTitle="${t('ui.security.function.title.functionManagement')}">
    <link href="${appCss('static/app/security/function-management.css')}" rel="stylesheet" />

    <div className="x-search-bar">
      <form>
        <div className="form-row align-items-center">

          <div className="col-auto">
            <label className="sr-only" htmlFor="functionCode"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.function.field.functionCode')}"}</div>
              </div>
              <input type="text" className="form-control" id="functionCode" data-x-name="searchField.functionCode"
                data-x-type="autoTrimText" />
            </div>
          </div>

          <div className="col-auto">
            <label className="sr-only" htmlFor="functionName"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.function.field.functionName')}"}</div>
              </div>
              <input type="text" className="form-control" id="functionName" data-x-name="searchField.functionName"
                data-x-type="autoTrimText" />
            </div>
          </div>

          <div className="col-auto">
            <label className="sr-only" htmlFor="remark"></label>
            <div className="input-group mb-2">
              <div className="input-group-prepend">
                <div className="input-group-text">{"${t('ui.security.resource.field.remark')}"}</div>
              </div>
              <input type="text" className="form-control" id="remark" data-x-name="searchField.remark"
                data-x-type="autoTrimText" />
            </div>
          </div>

          {/* 查询按钮 */}
          <div className="col-auto">
            <button type="button" className="btn btn-primary mb-2" data-x-ui="searchBtn">
              {"${t('ui.system.common.btn.search')}"}
            </button>
          </div>
        </div>
      </form>
    </div>

    <div className="x-tool-bar">
      <button type="button" className="btn btn-outline-primary mb-2 btn-sm" data-x-ui="createBtn">
        {"${t('ui.system.common.btn.create')}"}
      </button>
    </div>

    <table data-x-ui="functionTable" className="x-table-custom">
      <thead>
        <tr>
          <th data-field="id" data-visible="false">ID</th>
          <th data-field="functionCode">{"${t('ui.security.function.field.functionCode')}"}</th>
          <th data-field="functionName">{"${t('ui.security.function.field.functionName')}"}</th>
          <th data-field="remark">{"${t('ui.system.common.field.remark')}"}</th>
          <th>{"${t('ui.system.common.field.operate')}"}</th>
        </tr>
      </thead>
    </table>

    {/* "新建功能"弹出框 */}
    <div data-x-ui="newFunctionDialog" className="modal" tabIndex="-1">
      <ModalDialog dialogTitle="${t('ui.security.function.dialog.newFunction')}">
        <ModalBody>
          <form>
            <div className="form-group x-form-required">
              <label htmlFor="functionCode">{"${t('ui.security.function.field.functionCode')}"}</label>
              <input type="text" className="form-control" id="functionCode" name="functionCode" data-x-name="new.functionCode"
                placeholder={"${t('ui.system.common.placeholder.inputCodeLimitLength', 1, 50)}"} />
            </div>
            <div className="form-group x-form-required">
              <label htmlFor="functionName">{"${t('ui.security.function.field.functionName')}"}</label>
              <input type="text" className="form-control" id="functionName" name="functionName" data-x-name="new.functionName"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 1, 20)}"} />
            </div>
            <div className="form-group">
              <label htmlFor="remark">{"${t('ui.system.common.field.remark')}"}</label>
              <input type="text" className="form-control" id="remark" name="remark" data-x-name="new.remark"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 0, 200)}"} />
            </div>
          </form>
        </ModalBody>
        <ModalFooter confirmLabel="${t('ui.system.common.btn.save')}" cancelLabel="${t('ui.system.common.btn.cancel')}" />
      </ModalDialog>
    </div>

    {/* "编辑功能"弹出框 */}
    <div data-x-ui="editFunctionDialog" className="modal" tabIndex="-1">
      <ModalDialog dialogTitle="${t('ui.security.function.dialog.editFunction')}">
        <ModalBody>
          <form>
            <input type="hidden" id="id" name="id" data-x-name="edit.id" />
            <input type="hidden" id="versionNumber" name="versionNumber" data-x-name="edit.versionNumber" />

            <div className="form-group x-form-required">
              <label htmlFor="functionCode">{"${t('ui.security.function.field.functionCode')}"}</label>
              <input type="text" className="form-control" id="functionCode" name="functionCode" data-x-name="edit.functionCode"
                placeholder={"${t('ui.system.common.placeholder.inputCodeLimitLength', 1, 50)}"} />
            </div>
            <div className="form-group x-form-required">
              <label htmlFor="functionName">{"${t('ui.security.function.field.functionName')}"}</label>
              <input type="text" className="form-control" id="functionName" name="functionName" data-x-name="edit.functionName"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 1, 20)}"} />
            </div>
            <div className="form-group">
              <label htmlFor="remark">{"${t('ui.system.common.field.remark')}"}</label>
              <input type="text" className="form-control" id="remark" name="remark" data-x-name="edit.remark"
                placeholder={"${t('ui.system.common.placeholder.inputTextLimitLength', 0, 200)}"} />
            </div>
          </form>
        </ModalBody>
        <ModalFooter confirmLabel="${t('ui.system.common.btn.save')}" cancelLabel="${t('ui.system.common.btn.cancel')}" />
      </ModalDialog>
    </div>

    <div data-x-ui="assignResourceDialog" className="modal" tabIndex="-1">
      <AssignResourceDialog />
    </div>

    <div data-x-ui="assignPermissionDialog" className="modal" tabIndex="-1">
      <AssignPermissionDialog />
    </div>

    <script src="${appJs('app/common/js/table-selection-tabs.js')}" type="text/javascript"></script>
    <script src="${appJs('app/security/function/function-management.js')}" type="text/javascript"></script>
    <script src="${appJs('app/security/function/assign-resource-dialog.js')}" type="text/javascript"></script>
    <script src="${appJs('app/security/function/assign-permission-dialog.js')}" type="text/javascript"></script>
  </AppView>
</>
